<template>
  <div class="reports">
    <el-card>
      <div id="ehview" style="width: 750px,height: 400px"></div>
    </el-card>
  </div>
</template>

<script>
import {getReports} from '@/api/index'
export default {
  data() {
    return {
        list:{},
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },
  created(){
      this.echartsData()
  },
  methods: {
      async echartsData(){
          let {data,meta:{msg,status}}=await getReports();
          if(status!=200) return this.$message.error(msg);
          this.list={...this.options,...data}
          this.echartsInit(this.list)
      }
     , 
    echartsInit(options) {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("ehview"));
      // 绘制图表
      myChart.setOption(options);
    },
  },
};
</script>

<style lang="less" scoped>

#ehview {
    width: 750px;
    height: 400px;
}
</style>